package one.two.one;

import java.util.Random;

import edu.princeton.cs.algs4.Point2D;

public class MinOfRandom {

	public static void main(String[] args) {
		// int n = Integer.parseInt(args[0]);
		int n = 4;
		Point2D[] a = new Point2D[n];
		Random r = new Random();
		for (int i = 0; i < n; i++) {
			a[i] = new Point2D(r.nextDouble(), r.nextDouble());
		}
		double m = Math.sqrt(2);
		double d;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				d = java.awt.geom.Point2D.distance(a[i].x(), a[i].y(), a[j].x(), a[j].y());
				System.out.println(d);
				if (d < m)
					m = d;
			}
		}
		System.out.println(m);
	}

}
